<?php
class Form_Blog extends Zend_Form 
{
    protected $_blog;
    
    public function __construct($blog =null, $options = null){
        if($blog !== null){
            $this->_blog = $blog;
        }
        parent::__construct($options);    
    }
    
    public function init()
    {
        $this->setName('blog');
        
        $name = new Zend_Form_Element_Text('name', array('label'=>'Название блога: '));
        $submit = new Zend_Form_Element_Submit('submit');
        if($this->_blog === null){
            $submit->setLabel('Добавить');
             $this->setAction('/blog/update/');
        } else {
            $submit->setLabel('Редактировать');
             $this->setAction('/blog/update/id/' . $this->_blog->id);
        }
        
        $this->addElements(array($name, $submit));
        if($this->_blog !== null){
            $this->populate($this->_blog->getData());
        }
    }
}